#ifndef _CRT_SEM_H_
#define _CRT_SEM_H_

#include <crt_core.hpp>
#include <crt_sem.h>

#ifdef __cplusplus
extern "C" {
#endif

#if (TARGET_OS == OS_WIN)
typedef HANDLE _sem_t;
#elif (TARGET_OS == OS_POSIX)
typedef sem_t _sem_t;
#elif (TARGET_OS == OS_MACH)
typedef semaphore_t _sem_t;
#elif (TARGET_OS == OS_UNIX)
typedef int _sem_t;
#endif

int _sem_init(_sem_t* sem, unsigned int value);
int _sem_destroy(_sem_t* sem);
int _sem_post(_sem_t* sem);
int _sem_wait(_sem_t* sem);
int _sem_trywait(_sem_t* sem);
int _sem_wait_time(_sem_t* sem, unsigned int sec);

#ifdef __cplusplus
}
#endif

#endif
